package com.company.lifecycleCallbacks.config;

import com.company.bean.Student;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @Author: zhaopeng
 * @Date: Created in 16:27 2020/9/29
 * @Modified By:
 */
@Component
public class ProgramRegisterBeanPostProcessor implements BeanPostProcessor {

	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
		System.out.println("后置处理器postProcessBeforeInitialization");
		if (beanName.equals("student")) {
			Student student = (Student) bean;
			student.setAge(1);
			student.setName("11");
		}
		return bean;
	}

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		System.out.println("后置处理器postProcessAfterInitialization");
		return bean;
	}
}
